<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
      新增电梯
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
        #container {
            height: 85%;
            width: 100%;
        }

        .amap-icon img {
            width: 25px;
            height: 34px;
        }

        .amap-marker-label{
            border: 0;
            background-color: transparent;
        }

        .info{
            position: relative;
            top: 0;
            right: 0;
            min-width: 0;
        }
        .amap-marker-label{background-color: #fff; padding: 10px; color: red;}
    </style>
</head>

<body>
<div class="layui-tab-content">
    <div class="modal-body">
        <div class="row">
            <form action="" class="layui-form">
                <div class="nav-tabs-custom layui-form-pane">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" id="mapInfo">基本信息</a></li>
                        <li><a href="#tab_2" data-toggle="tab">电梯参数 </a></li>
                        <li><a href="#tab_3" data-toggle="tab">其他信息 </a></li>
                        <li><a href="#tab_4" data-toggle="tab" onclick="aa()">电梯位置 </a></li>

                    </ul>
                    <div class="tab-content" style="padding: 0;">
                        <div class="tab-pane active" id="tab_1">
                            <h3 style="text-align: left;">基本信息: <span style="color: red;">（必填）</span> </h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">使用单位</label>
                                <div class="layui-input-block">
                                    <select name="companyId" id="companyId" lay-filter="brickType">
                                        <option value="">---</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">项目名称</label>
                                <div class="layui-input-block">
                                    <select name="projectId" id="projectId" lay-search="">
                                        <option value="">---</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">电梯位置</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="address" id="address" placeholder="电梯位置">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">电梯类型</label>
                                <div class="layui-input-block">
                                    <select name="typeId" id="typeId" lay-search="">
                                        <option value="">---</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">电梯品牌</label>
                                <div class="layui-input-block">
                                    <select name="brandId" id="brandId" lay-search="">
                                        <option value="">---</option>
                                    </select>
                                </div>
                            </div>
                            <h3 style="text-align: left;">使用证编号:</h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">使用证号</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="usenumber" id="usenumber" placeholder="使用证号">
                                </div>
                            </div>
                            <h3 style="text-align: left;">保养设置:</h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">保养模板</label>
                                <div class="layui-input-block">
                                    <select name="maintainmodelId" id="maintainmodelId" lay-search="">
                                        <option value="">---</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">电子工单</label>
                                <div class="layui-input-block">
                                    <select name="iselectronicWorksheets" id="iselectronicWorksheets" lay-search="">
                                        <option value="">---</option>
                                        <option value="开启">开启</option>
                                        <option value="关闭">关闭</option>
                                    </select>
                                </div>
                            </div>
                            <h3 style="text-align: left;">维保人员:</h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">维保人员</label>
                                <div class="layui-input-block">
                                    <select name="personId" id="personId" lay-search="">
                                        <option value="">---</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="tab-pane" id="tab_2" style="height: 460px;padding-top: 5px">
                            <h3 style="text-align: left;">设备信息：</h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">制造单位</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="makecompany" id="makecompany" placeholder="制造单位">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">安装单位</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="installcompany" id="installcompany" placeholder="安装单位">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">运行方式</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="operationmode" id="operationmode" placeholder="运行方式">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">设备型号</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="equipmentmodel" id="equipmentmodel" placeholder="设备型号">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">出厂编号</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="factorynumber" id="factorynumber" placeholder="出厂编号">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">控制方式</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="controlmode" id="controlmode" placeholder="控制方式">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">额定速度</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="speed" id="speed" placeholder="额定速度">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">载重</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="maxload" id="maxload" placeholder="载重">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">层站数</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="floorsnumber" id="floorsnumber" placeholder="层站数">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">注册单位</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="regcompany" id="regcompany" placeholder="注册单位">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">注册代码</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="regcode" id="regcode" placeholder="注册代码">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">管理人员</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="manager" id="manager" placeholder="管理人员">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系电话</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="tel" id="tel" placeholder="管理人员">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">重点场所</label>
                                <div class="layui-input-block">
                                    <select name="isKeyplaces" id="isKeyplaces" lay-search="">
                                        <option value="">---</option>
                                        <option value="是">是</option>
                                        <option value="否">否</option>
                                    </select>
                                </div>
                            </div>



                            <div class="layui-form-item">
                                <label class="layui-form-label">其他信息</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="otherinformation" id="otherinformation" placeholder="其他信息">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">运行次数</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="runsnum" id="runsnum" placeholder="运行次数">
                                </div>
                            </div>
                            <h3 style="text-align: left;">设备信息：</h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">制造日期</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="开始日" name="makeDate" id="makeDate">
                                </div>
                                <label class="layui-form-label">校验日期</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="截止日" name="checkDate" id="checkDate">
                                </div>

                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">限速器下次校验日期</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="开始日" name="nextcheckDate" id="nextcheckDate">
                                </div>
                                <label class="layui-form-label">下次125试验日期</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="截止日" name="nexttestDate" id="nexttestDate">
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="tab_3" style="overflow: auto;">
                            <h3 style="text-align: left;">年检信息：</h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">检验人员</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="checkperson" id="checkperson" placeholder="检验人员">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">检验单位</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="checkcompany" id="checkcompany" placeholder="检验单位">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">单位电话</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="companytel" id="companytel" placeholder="单位电话">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">报告编号</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="reportcode" id="reportcode" placeholder="报告编号">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">年检日期</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="开始日" name="yearcheckDate" id="yearcheckDate">
                                </div>
                                <label class="layui-form-label">下次年检</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="截止日" name="nextyearcheckDate" id="nextyearcheckDate">
                                </div>

                            </div>
                            <h3 style="text-align: left;">合同信息：</h3>
                            <div class="layui-form-item">
                                <label class="layui-form-label">维保开始日</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="维保开始日" name="maintenanceStartDate" id="maintenanceStartDate">
                                </div>
                                <label class="layui-form-label">维保到期日</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="维保到期日" name="maintenanceEndDate" id="maintenanceEndDate">
                                </div>
                                <label class="layui-form-label">付款日期</label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  class="layui-input" placeholder="付款日期" name="paymentDate" id="paymentDate">
                                </div>

                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">税收票证</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="taxticket" id="taxticket" placeholder="税收票证">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系人员</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="contactperson" id="contactperson" placeholder="联系人员">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系电话</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="contacttel" id="contacttel" placeholder="联系电话">
                                </div>
                            </div>
                            <div class="layui-form-item" >
                                <label class="layui-form-label">保养方式</label>
                                <div class="layui-input-block">
                                    <select name="maintenancetype" id="maintenancetype" lay-search="">
                                        <option value="">---</option>
                                        <option value="0">清包</option>
                                        <option value="1">半包</option>
                                        <option value="2">全包</option>
                                        <option value="3">质保</option>
                                        <option value="4">大包</option>
                                        <option value="5">小包</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">配件约定</label>
                                <div class="layui-input-block">
                                    <input  autocomplete="off"  type="text" class="layui-input" name="parts" id="parts" placeholder="配件约定">
                                </div>
                            </div>
                            <div class="layui-form-item" style="display: none;">
                                <label class="layui-form-label">维保类型</label>
                                <div class="layui-input-block">
                                    <select name="maintype" id="maintype" lay-search="">
                                        <option value="半月保">半月保</option>
                                        <option value="季度保">季度保</option>
                                        <option value="半年保">半年保</option>
                                        <option value="年度保">年度保</option>

                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">电梯保险</label>
                                <div class="layui-input-block">
                                    <select name="ismaintenance" id="ismaintenance" lay-search="">
                                        <option value="">---</option>
                                        <option value="0">包含</option>
                                        <option value="1">不包含</option>
                                    </select>
                                </div>
                            </div>

                        </div>

                        <div class="tab-pane" id="tab_4" style="height: 460px;overflow: hidden;">
                            <div id="mapBox" style=" position: relative;">

                                <div class="layui-form-item">
                                    <label class="layui-form-label">详细地址</label>
                                    <div class="layui-input-block">
                                        <input  autocomplete="off"  type="text" id="addressdetail" readonly  class="layui-input"  name="addressdetail" placeholder="详细地址">
                                        <input  autocomplete="off"  type="hidden" id="addressLongitude" name="addressLongitude">
                                        <input  autocomplete="off"  type="hidden" id="addressLatitude" name="addressLatitude">
                                    </div>
                                </div>

                            </div>
                            <div id="container">

                            </div>
                            <div id="tip">
                                <input  autocomplete="off"  type="text" id="suggestId" name="suggestId" placeholder="搜索关键字"/>
                                <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
                            </div>

                        </div>

                    </div>
                    <div style="text-align: center; margin-top: 20px;" class="layui-form-item">
                        <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                            提交
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>


</div>
</body>


<script type="text/javascript" src="../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../js/pub.js"></script>
<script type="text/javascript" src="../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>


<script>


    layui.use(['laydate', 'form', 'layer'],
        function () {
            var form = layui.form;
            var layer = layui.layer;
            var laydate = layui.laydate;

            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#makeDate' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#checkDate' //指定元素
            });

            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#nextcheckDate' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#nexttestDate' //指定元素
            });
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#yearcheckDate' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#nextyearcheckDate' //指定元素
            });
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#maintenanceStartDate' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#maintenanceEndDate' //指定元素
            });
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#paymentDate' //指定元素
            });


            let request2 = {
                url: 'maintenance/company/findAll',
                method: "GET",
                data:{userId:$userId,}

            };
            sendRequest(request2, (res) => {
                let x = res.data;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#companyId").append(opt);
                });
                form.render('select');
            });

            let request3 = {
                url: 'maintenance/project/findAll',
                method: "GET",
                data:{userId:$userId,}
            };
            sendRequest(request3, (res) => {
                let x = res.data;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#projectId").append(opt);
                });
                form.render('select');
            });


            let request4 = {
                url: 'user/getMaintenanceUser',
                method: "GET",
                data:{userId:$userId,}
            };
            sendRequest(request4, (res) => {
                let x = res;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.nickname + "</option>");
                    $("#personId").append(opt);
                });
                form.render('select');
            });

            let request5 = {
                url: 'maintenance/elevatortype/gettypeData',
                method: "GET",
                data:{userId:$userId,}
            };
            sendRequest(request5, (res) => {
                let x = res;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#typeId").append(opt);
                });
                form.render('select');
            });


            let request6 = {
                url: 'maintenance/elevatorbrand/getbrandData',
                method: "GET",
                data:{userId:$userId,}
            };
            sendRequest(request6, (res) => {
                let x = res;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#brandId").append(opt);
                });
                form.render('select');
            });

            let request7 = {
                url: 'maintenance/maintainmodel/findAll',
                method: "GET",
                data:{userId:$userId,}
            };
            sendRequest(request7, (res) => {
                let x = res;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#maintainmodelId").append(opt);
                });
                form.render('select');
            });

            form.render('select');
            form.on('select(brickType)', function(data){
                let opthtml = $("<option value=''>请选择</option>");
                $("#projectId").html(opthtml);
                form.render('select');

                var val=data.value;
                if(val!=""){
                    let request = {
                        url: 'maintenance/project/findByCompanyId',
                        data: {
                            companyId: val,
                            userId:$userId,
                        },
                        method: "POST",
                    };
                    sendRequest(request, (res) => {
                        let x = res.data;
                        $.each(x, function (index, item) {
                            let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                            $("#projectId").append(opt);
                        });
                        form.render('select');
                    });
                }

            });


            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    var companyId = $("#companyId").val();
                    var projectId = $("#projectId").val();
                    var address = $("#address").val();
                    var typeId = $("#typeId").val();
                    var brandId = $("#brandId").val();
                    var usenumber = $("#usenumber").val();
                    var maintainmodelId = $("#maintainmodelId").val();
                    var iselectronicWorksheets = $("#iselectronicWorksheets").val();
                    var personId = $("#personId").val();
                    var addressdetail = $("#addressdetail").val();


                    if(companyId == ""){
                        layer.msg("请选择使用单位！", {
                            icon: 5
                        });
                        return false;
                    }else if(projectId== ""){
                        layer.msg("请选择项目！", {
                            icon: 5
                        });
                        return false;
                    }else if(address== ""){
                        layer.msg("请填写电梯位置！", {
                            icon: 5
                        });
                        return false;
                    }else if(typeId== ""){
                        layer.msg("请选择电梯类型！", {
                            icon: 5
                        });
                        return false;
                    }else if(brandId== ""){
                        layer.msg("请选择电梯品牌！", {
                            icon: 5
                        });
                        return false;
                    }else if(usenumber== ""){
                        layer.msg("请填写使用证号！", {
                            icon: 5
                        });
                        return false;
                    }else if(maintainmodelId== ""){
                        layer.msg("请选择保养模板！", {
                            icon: 5
                        });
                        return false;
                    }else if(iselectronicWorksheets== ""){
                        layer.msg("请选择电子工单！", {
                            icon: 5
                        });
                        return false;
                    }else if(personId== ""){
                        layer.msg("请选择维保人员！", {
                            icon: 5
                        });
                        return false;
                    }else if(addressdetail== ""){
                        layer.msg("请在地图上选择电梯详细位置！", {
                            icon: 5
                        });
                        return false;
                    }else{
                        let form = data.field;

                        form.maintenancepersonIdstring =","+$("#personId").val()+",";
                        form.userId=$userId;
                        let request = {
                            url: 'maintenance/elevator/add',
                            data: form,
                            method: "post",
                        };
                        sendRequest(request, (data) => {
                            if (data.code === 0) {
                                layer.alert("操作成功", {
                                        icon: 6
                                    },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                        parent.reload();
                                    });
                            } else {
                                layer.alert(data.msg, {
                                    icon: 5
                                })
                            }
                        });
                        return false;
                    }


                });
        });




    const vm = new Vue({
        el: "#app",
        created() {

        },
        computed: {},
        methods: {

        },


    });



</script>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=jA0VzOF5uYehineGKLNc1FBIPGDSyO7R"></script>
<script>

    function G(id) {
        return document.getElementById(id);
    }

    function aa(){

        var map = new BMap.Map("container");
        map.centerAndZoom("淮北",12);
        map.enableScrollWheelZoom(true);

        var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
            {
                "input" : "suggestId",
                "location" : map
            });

        ac.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
            var str = "";
            var _value = e.fromitem.value;
            var value = "";
            if (e.fromitem.index > -1) {
                value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
            }
            str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

            value = "";
            if (e.toitem.index > -1) {
                _value = e.toitem.value;
                value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
            }
            str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
            G("searchResultPanel").innerHTML = str;
        });

        var myValue;
        ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
            var _value = e.item.value;
            myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
            G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;

            setPlace();
        });
        var geoc = new BMap.Geocoder();
        map.addEventListener('click', function (e) {

            map.clearOverlays();
            $("#addressLongitude").val(e.point.lng);
            $("#addressLatitude").val(e.point.lat);


            var marker1 = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat));
            map.addOverlay(marker1);

            var pt =e.point;
            geoc.getLocation(pt, function(rs){

                if(rs.surroundingPois.length==0){
                    $('#addressdetail').val(rs.address);
                }else{
                    $('#addressdetail').val(rs.address+rs.surroundingPois[0].title);
                }

            })
        });

        function setPlace(){
            map.clearOverlays();    //清除地图上所有覆盖物
            function myFun(){
                var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
                map.centerAndZoom(pp, 20);
                //添加标注
            }
            var local = new BMap.LocalSearch(map, { //智能搜索
                onSearchComplete: myFun
            });
            local.search(myValue);
        }
    }




</script>


<style>
    #container{position: relative;}

    #tip {
        background-color: #ddf;
        color: #333;
        border: 1px solid silver;
        box-shadow: 3px 4px 3px 0px silver;
        position: absolute;
        top: 120px;
        right: 10px;
        border-radius: 5px;
        overflow: hidden;
        line-height: 20px;
        z-index: 99999;
    }
    #tip input[type="text"] {
        height: 25px;
        border: 0;
        padding-left: 5px;
        width: 280px;
        border-radius: 3px;
        outline: none;
    }
</style>
</html>
